#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Sensor, S2,     SonarSensor,         sensorSONAR)
#pragma config(Sensor, S3,     LightSensor,         sensorLightActive)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  int mValue = 15;      //Motor power value
  //int threshold = 20;   //Sonar sensor threshold value

  while(true)		//Run continuously
  {
    if(SensorValue(SonarSensor) > 26)		// If the Ultrasonic sensor is greater than 20, set movement to 15
    {
      mValue = 15;
    }
     else if(SensorValue(SonarSensor) < 24)	// If the Ultrasonic sensor is less than 20, set movement to -15
    {
      mValue = -15;
    }
    else 	// If the Ultrasonic sensor is equal to 20, set movement to 0
    {
      mValue = 0;
    }

    motor[motorD]= mValue;
    motor[motorE]= mValue;
  }
}
